{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "img_width = 28\n",
    "img_height = 28\n",
    "channels = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "batch_size = 500\n",
    "num_epochs = 80\n",
    "iterations = 3\n",
    "nb_augmentation = 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "fashion_classes = {0:'T恤',\n",
    "1:'裤子',\n",
    "2:'套衫',\n",
    "3:'裙子',\n",
    "4:'外套',\n",
    "5:'凉鞋',\n",
    "6:'汗衫',\n",
    "7:'运动鞋',\n",
    "8:'包',\n",
    "9:'踝靴',}\n",
    "mnist_classes =[i for i in range (10)]\n",
    "num_classes =10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train Samples 60000\n",
      "Test Samples 10000\n"
     ]
    }
   ],
   "source": [
    "import tensorflow_datasets as tfds\n",
    "train_fasion_mnist=tfds.as_numpy(tfds.load(\"fashion_mnist\",split=\"train\",data_dir=\"./\",download=False,batch_size=-1))\n",
    "Y_train,X_train=train_fasion_mnist[\"image\"],train_fasion_mnist[\"label\"]\n",
    "test_fasion_mnist = tfds.as_numpy(tfds.load(\"fashion_mnist\",split=\"test\",data_dir=\"./\",download=False,batch_size=-1))\n",
    "X_test,Y_test=test_fasion_mnist[\"image\"],test_fasion_mnist[\"label\"]\n",
    "print(\"Train Samples\",len(X_train))\n",
    "print(\"Test Samples\",len(Y_test))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAASUAAAElCAYAAACiZ/R3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29md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H//Mp0+flub29vY6/dyPHz+2zuzs7HT6mfyTmxIQRZSAKKIERBElIIooAVFECYgiSkAUUQKiWJ68ZqrPtVafiZ2YyPwRePToUWnu3bt3pbmNjY3S3PT0dGmO0XFTAqKIEhBFlIAoogREESUgiigBUUQJiCJKQBRRAqJkrvPyP83NzZXmvn79WpqrbDDPz8+XzroKTdOU5sbGar9/+/3+Zb4OHXBTAqKIEhBFlIAoogREESUgiigBUUQJiCJKQBRRAqLY6L5mhsNhae7s7Kw0NzMz0zozNTVVOqtLXW+RV98sn52d7fRzuTg3JSCKKAFRRAmIIkpAFFECoogSEEWUgCiiBESxPHnNVJ/DrS5ZVpcK/7TKUmevV3++tvrnXFlZKc0xOm5KQBRRAqKIEhBFlIAoogREESUgiigBUUQJiCJKQBQb3dfM1tZWae7Dhw+luerm95928+bNTs+rbn7funWr08/l4tyUgCiiBEQRJSCKKAFRRAmIIkpAFFECoogSEEWUgCg2uq+Z1dXV0lzTNKW5hYWFy3ydkXny5ElpbnJysjRX3ei+ceNGaY7RcVMCoogSEEWUgCiiBEQRJSCKKAFRRAmIIkpAFFECotjovmY+f/5cmjs5OSnN/fr16zJfZ2QGg0Fp7ujoqDQ3NzdXmqv+vTE6bkpAFFECoogSEEWUgCiiBEQRJSCKKAFRRAmIYnnymnn58mVprrpU+Pz588t8nZHZ3t4uzb148aI0t7OzU5rb3NwszTE6bkpAFFECoogSEEWUgCiiBEQRJSCKKAFRRAmIIkpAlH7TNPXhfv+w1+t9Gt3XAf6P/atpmtW2oQtFCWDU/PMNiCJKQBRRAqKIEhBFlIAoogREESUgiigBUUQJiPI3NuJeI8vLUxMAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 360x360 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "类型: 裤子\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "plt.figure(figsize=(5,5))\n",
    "i=np.random.randint(len(Y_train))\n",
    "img = Y_train[i].reshape(28, 28)\n",
    "plt.xticks([])\n",
    "plt.yticks([])\n",
    "plt.grid(False)\n",
    "plt.imshow(img, cmap=plt.cm.binary)\n",
    "plt.show()\n",
    "print(\"类型:\",fashion_classes[X_train[i]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
